# Maintainer: Zach Bacon <11doctorwhocanada@gmail.com>

_realname=faac
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.28
pkgrel=2
pkgdesc='FAAC is an AAC audio encoder (mingw-w64)'
arch=('any')
url='http://www.audiocoding.com/faac.html'
license=('GPL2')
source=("https://downloads.sourceforge.net/${_realname}/${_realname}-${pkgver}.tar.gz"
        "make-shared.patch")
sha256sums=('c5141199f4cfb17d749c36ba8cfe4b25f838da67c22f0fec40228b6b9c3d19df'
            '35b1bcaa4535d3d7ee7df773a6d4d650ba5b033285d466a2392f307973207890')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -Np1 -i ${srcdir}/make-shared.patch
}

build() {
  [ -d "${srcdir}"/build-${CARCH} ] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared \
    --without-mp4v2

  make
}

package() {
  cd "${srcdir}"/build-${CARCH}
  make install DESTDIR="${pkgdir}"
}
